<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <meta name="applicable-device" content="pc">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="icon" href="/icon.png" />
    
    <link rel="stylesheet" href="/static/index/lib/bootstrap.css">
    <link rel="stylesheet" href="/static/index/css/common.css">
    <link rel="stylesheet" href="/static/index/css/login.css">
    <link rel="stylesheet" href="/static/index/css/reset.css">
    <script src="/static/index/lib/jquery-2.1.4.js"></script>
    <script type="text/javascript" src="/static/index/lib/template.js"></script>
    <script>
        var _hmt = _hmt || [];
        (function() {
          var hm = document.createElement("script");
          hm.src = "https://hm.baidu.com/hm.js?8b340ebdd740974de9d621b14ab09b43";
          var s = document.getElementsByTagName("script")[0]; 
          s.parentNode.insertBefore(hm, s);
        })();
    </script>
</head>

<body>
    {include file="public/push"}
    <div class="widthFullScreen loginHeaderContainer">
        <div class="wdSafe headerWrap clearfix">
            <img class="pull-left" style="height: 90px;width: auto;" src="https://img.qikuai100.com/logo.png" alt="">
            <a href="/" class="pull-left reginTitle">返回首页</a>
            <h3 class="pull-right tel_custorm">客服热线：<a href="tel:17343030506">17343030506</a></h3>
        </div>
        <div class="line_header widthFullScreen"></div>
    </div>
    <div class="widthFullScreen login_box">
        <div class="wdSafe">
            <div class="login_news pull-right">
                <div class="login_form">
                    <p class="login_title" style="padding-top: 35px">欢迎登录</p>
                    <form class="form-horizontal">
                        <div class="form-group text-left">
                            <label for="phoneNum" class="col-sm-2 control-label">手机</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" id="phoneNum" placeholder="请输入手机号码">
                            </div>
                        </div>
                        <div class="form-group text-left">
                            <label for="password" class="col-sm-2 control-label">密码</label>
                            <div class="col-sm-10">
                                <input type="password" autocomplete="password" class="form-control" id="password" placeholder="请输入6位以上密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-6">
                                <div class="checkbox" style="padding-left: 15px;">
                                    <label>
                                        <input type="checkbox"> 两周内免登录
                                    </label>
                                </div>
                            </div>
                            <div class="col-sm-6" style="text-align: right;margin-top: 7px;">
                                <a class="forget_pwd" href="/user/forgetPwd">忘记密码？</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <input type="button" value="立即登录" onclick="login()" class="sign_in" name="">
                        </div>
                    </form>
                    <div class="regin_note">没有账号，立即<a href="/user/reg">注册</a></div>
                </div>
            </div>
        </div>
    </div>
    {include file="public/footer"}
    <script src="/static/index/layer/layer.js"></script>

    <script>
        var baseUrl = 'https://api.qikuai100.com/';
        $(function() {

        });

        /**
        * 登录
        */
        function login(){
            
            var phone = $("#phoneNum").val(),
                password1 = $("#password").val();
           
            var result = isPhoneNum();
            if(!result){
                return;
            }
            if($.trim(password1) == ""){
                layer.msg("请输入密码");
                return;
            }
            if($.trim(password1).length < 6){
                layer.msg("请输入6位以上的密码");
                return;
            }
            $.ajax({
                type: "POST",
                url: baseUrl + "api/auth/login",
                data: {
                    "phone": phone,
                    "password": password1
                },
                success: function(result) {
                    if(result.ret == 0){
                        localStorage.setItem("uid", result.data.uid);
                        localStorage.setItem("avatar", result.data.avatar);
                        localStorage.setItem("name", result.data.name);
                        window.location.href = '/index/index';
                    }else{
                        layer.msg(result.res_info);
                    }
                }
            });
        }

        //校验手机号是否合法
        function isPhoneNum() {
            var phone_1 = $("#phoneNum").val();
            var myreg = /^1[34578]\d{9}$/;
            if(!myreg.test(phone_1)) {
                layer.msg("请输入有效的手机号码");
                return false;
            } else {
                return true;
            }
        }
    </script>
</body>

</html>